import Page
from Page import Carpark
from Base.Base import Base
from selenium.webdriver.common.by import By


class CarparkSongReplyingPage(Base):
    """
    车乐汇回答页面

    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 关闭按钮
        self.replying_close_btn = (By.XPATH, Carpark.RESOURCE_ID_SONG.format("iv_close"))

        # 猜歌名标题提示
        self.replying_title_text = (By.XPATH, Carpark.RESOURCE_ID_SONG.format("tv_question"))

        # 歌曲提示
        self.replying_tip_text = (By.XPATH, Carpark.RESOURCE_ID_SONG.format("tv_tip"))

        # 回答中图标
        self.replying_rhythm_icon = (By.XPATH, Carpark.RESOURCE_ID_SONG.format("iv_voice_anim"))

        # 第几题
        self.replying_questions_text = (By.XPATH, Carpark.RESOURCE_ID_SONG.format("tv_title"))

        # 暂停按钮
        self.replying_stop_btn = (By.XPATH, Carpark.RESOURCE_ID_SONG.format("iv_state"))


    def click_close(self):
        """
         点击关闭按钮

         :return:None
         """
        self.click_element(self.replying_close_btn)

    def get_title(self):
        """
        获取回答题目标题

        :return:获取元素
        """
        return self.find_element_o(self.replying_title_text)

    def get_tip(self):
        """
        获取猜歌名提示

        :return:获取元素
        """
        return self.find_element_o(self.replying_tip_text)

    def get_questions(self):
        """
        获取第几题文本

        :return:获取元素
        """
        return self.find_element_o(self.replying_questions_text)

    def get_rhythm(self):
        """
        获取律动图标

        :return:获取元素
        """
        return self.find_element_o(self.replying_rhythm_icon)

    def click_stop(self):
        """
         点击开始回答按钮

         :return:None
         """
        self.click_element(self.replying_stop_btn)

    def is_display_carpark_replying(self):
        """
        查看是否进入猜歌名回答中页面

        :return:
        """
        return self.is_display(self.replying_rhythm_icon)
